import csv
data = [
    ['姓名','年龄','性别'],
    ['张三',22,'男'],
    ['李四',33,'女']
]

with open('base.csv','w',encoding='utf-8',newline='') as f:
    writer = csv.writer(f)
    for d in data:
        writer.writerow(d)
